package com.atguigu.day23.work;

import org.junit.Test;

import java.io.*;

public class Work6 {
    @Test
    public void w1() throws IOException {
        Message msg = new Message("张三", "李四", "约饭", System.currentTimeMillis());
        ObjectOutputStream ob = new ObjectOutputStream(new FileOutputStream("message.dat"));
        ob.writeObject(msg);
        ob.close();
    }

    @Test
    public void w2() throws IOException, ClassNotFoundException {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("message.dat"));
        Object msg = ois.readObject();
        System.out.println(msg);
        ois.close();
    }
}
